package com.ntlg.jpa.utils;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class JpaUtils {
   private static EntityManagerFactory factory =null;
    static {
      factory = Persistence.createEntityManagerFactory("myJpa");
    }

    public static EntityManager getEntityManager(){
        EntityManager em = factory.createEntityManager();
        return em;
    }

    public static void closeConnect(EntityManager em){
        em.close();
        factory.close();
    }

}
